class MyPromise {
  constructor(executor) {
    // 初始化
    this.init();
    executor(this.resolve.bind(this), this.reject.bind(this));
  }
  init() {
    this.state = "pedding";
    this.result = null;
  }
  resolve(value) {
    this.state = "resolve";
    this.result = value;
  }
  reject(err) {
    this.state = "reject";
    this.result = err;
  }
  then() {}
}
let p1 = new MyPromise((resolve, reject) => {
  resolve("成功");
  reject("失败");
});
console.log("p1", p1);

let p2 = new MyPromise((resolve, reject) => {
  reject("失败");
  resolve("成功");
});
console.log("p2", p2);

let p3 = new MyPromise((resolve, reject) => {
  throw "报错";
});
console.log("p3", p3);
